import url from "./url";
import { request } from "./url";

export const deleteRule = (data: string) => {
  return request.post(url.DELETE_RULE + data);
};
export const editRule = (id: string, data: any) => {
  return request.post(url.RULE_EDIT + id, data);
};

export const ruleChainNode = (data: any) => {
  return request.post(url.RULE_CHAIN_NODE_LIST, data);
};

export const deleteNode = (id: string) => {
  return request.post(url.NODE_DELETE + id);
};

export const byIdGetChain = (id: any) => {
  return request.post(url.RULE_CHAIN_GET_BY_ID + id);
};
export const saveRuleChain = (data: any) => {
  return request.post(url.RULE_CHAIN_SAVE, data);
};
export const deleteRuleChain = (id: string | number) => {
  return request.post(url.RULE_CHAIN_DELETE + id);
};
export const queryPageRuleChain = (data: any) => {
  return request.post(url.RULE_CHAIN_QUERY_PAGE, data);
};
export const editRuleChain = (id: string | any, data: any) => {
  return request.post(url.RULE_CHAIN_EDIT + id, data);
};

export const deleteGeneralParams = (id: string) => {
  return request.post(url.GENERAL_DELETE + id);
};

//改进接口
export const  getDeviceList= () => {
  return request.get(url.TRUNK_LIST);
};
export const getExpressPoints = () => {
  return request.get(url.EXPRESS_POINTS);
};
export const getFunctionList = () => {
  return request.get(url.EXPRESS_FUNCS);
};

export const getDeviceTypeList = () => {
  return request.get(url.EXPRESS_CORE);
};
//改版接口
export const deleteChainNode = (id: any) => {
  return request.post(url.DELETE_NODE + id);
};
export const getChainAllNode = (id: any) => {
  return request.post(url.QUERY_NODE_BY_CHAIN_ID + id);
};
export const getChainNodeDetail = (id: any) => {
  return request.post(url.QUERY_NODE_DETAIL_BY_ID + id);
};
export const saveChainNode = (data: any) => {
  return request.post(url.SAVE_OR_UPDATE, data);
};
export const upateNodeRelation = (data: any) => {
  return request.post(url.UPDATE_NODE_RELATION, data);
};

//保存按钮触发
export const deployChain = (id: any) => {
  return request.post(url.CHAIN_DEPLOY + id);
};
export const exportRule = (id: any) => {
  return request.post(url.EXPORT_RULE, null, {
    params: { ruleChainId: id },
    responseType: "blob",
  });
};
export const importRule = (data: any) => {
  return request.post(url.IMPORT_RULE, data, {
    headers: { "Content-Type": "multipart/form-data" },
  });
};
